// index.js
const config = require('../../config/index')
Page({
  data: {
    baseUrl: config.baseUrl,
    rateFlor: null,
    amtCeiling: '',
    prodName:'',
    theme: wx.getStorageSync('InvoiceLoanTheme') || ''
  },
  onLoad(options) {
    // 分割整数和小数部分
    const parts = options.amtCeiling.toString().split('.');
    // 格式化整数部分
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
    this.setData({
      rateFlor: Number(options.rateFlor),
      amtCeiling: parts.join('.'),
      prodName: options.prodName,
      theme: wx.getStorageSync('InvoiceLoanTheme') || ''
    })
    wx.setNavigationBarTitle({
      title:  `雪莲发票贷·(${options.type==='USER'?'对私':'对公'})`,
    })
  },
  // 简易双向数据绑定
  handInputChange (e) {
    this.setData({
      [`formData.${e.target.id}`]: e.detail.value
    })
  },
  bindViewTap() {
    wx.navigateTo({
      url: '/pages/login/index'
    })
  }
})
